package com.sky.controller.user;

import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.result.Result;
import com.sky.service.SetMealService;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userSetMealController")
@RequestMapping("/user/setmeal")
public class SetMealController {
    @Autowired
    private SetMealService setMealService;

    @GetMapping("/list")
    @Cacheable(cacheNames = "setmealCache",key = "#categoryId")
    public Result list(long categoryId) {
        //根据分类id查询套餐
        List<SetmealVO> setmeals = setMealService.getSetmealsByCategoryId(categoryId);
        return Result.success(setmeals);
    }
    @GetMapping("/dish/{id}")
    public Result getDishBySetMealId(@PathVariable Long id) {
        List<DishItemVO> dishItemVOList = setMealService.getDishBySetMealId(id);
        return Result.success(dishItemVOList);
    }

}
